<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	request.setCharacterEncoding("UTF-8");
	String htmlData = request.getParameter("content1") != null ? request.getParameter("content1") : "";
%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="<%=path%>/My97DatePicker/WdatePicker.js"></script>
<link rel="stylesheet" type="text/css" href="<%=path%>/CSS/backLayout.css">
<style type="text/css">
input[type=checkbox]{padding:0px; margin:0px; text-align:right;width: 15px}
.div_input {
  width: 500px;
  height: 40px;
  }
</style>
</head>
<body style="background: #f5f5f5">
<div class="main">
	<div class="weizhi">
	<c:if test="${empty systemParameter}">
		系统参数>>系统参数设置>>新增
	</c:if>
	<c:if test="${not empty systemParameter}">
		系统参数>>系统参数设置>>修改
	</c:if>
	</div>
	<div class="div_body" style="box-shadow: 0 0 5px #cccccc;">
		<div class="div_form">
			<form action="<%=path%>/DrivingSys/editSysetmParamenter" class="form" onsubmit="return submit2();">
			<c:if test="${empty systemParameter}">
				<div class="jczl">
						<div class="div_input">
							<span class="gn_name">财务组织&nbsp;:&nbsp;</span>
							<input type="text"  value="${department.fnameL2}" readonly="readonly" style="color: gray;">
						</div>
						<div class="div_input">
							<span class="gn_name">编码&nbsp;:&nbsp;</span>
							<input type="text" name="fnumber" value="${fnumber}" readonly="readonly" style="color: gray;">
						</div>
						<div class="div_input">
							<span class="gn_name">名称&nbsp;:&nbsp;</span>
							<input type="text" name="fnameL2" class="name" onblur="yz()">
                            <span class="required">必填</span>
						</div>
					<div class="div_input">
						<span class="gn_name">描述&nbsp;:&nbsp;</span>
						<input type="text" name="fdescriptionL2">
					</div>
						<div class="div_input">
							<span class="gn_name">数值&nbsp;:&nbsp;</span>
							<input type="text" name="cfnumbers" id="cfnumbers">
							<span style="font-size: 14px;color: red;display: none" class="haoyou">请输入数字</span>
						</div>
						<div class="div_input">
							<span class="gn_name">启用&nbsp;:&nbsp;</span>
							<input type="checkbox" class="checkbox" name="cfenabled2" value="" id="cfenabled2"/>
							<input type="hidden"  name="cfenabled" id="cfenabled"/>
						</div>
					</div>
				</c:if>
				<c:if test="${not empty systemParameter}">
				<div class="jczl">
						<div class="div_input">
							<span class="gn_name">财务组织&nbsp;:&nbsp;</span>
							<input type="text"  value="${department.fnameL2}" readonly="readonly" style="color: gray;">
						</div>
						<div class="div_input">
							<span class="gn_name">编码&nbsp;:&nbsp;</span>
							<input type="text" name="fnumber" value="${systemParameter.fnumber}" readonly="readonly" style="color: gray;">
							<input type="hidden" name="fid" value="${systemParameter.fid}">
						</div>
						<div class="div_input">
							<span class="gn_name">名称&nbsp;:&nbsp;</span>
							<input type="text" name="fnameL2" value="${systemParameter.fnameL2}" class="name"
								   onblur="yzEdit()">
							<input type="hidden" value="${systemParameter.fnameL2}">
                            <span class="required">必填</span>
						</div>
					<div class="div_input">
						<span class="gn_name">描述&nbsp;:&nbsp;</span>
						<input type="text" name="fdescriptionL2" value="${systemParameter.fdescriptionL2}">
					</div>
						<div class="div_input">
							<span class="gn_name">数值&nbsp;:&nbsp;</span>
							<input type="text" name="cfnumbers" id="cfnumbers" value="${systemParameter.cfnumbers}">
							<span style="font-size: 14px;color: red;display: none" class="haoyou">请输入数字</span>
						</div>
						<div class="div_input">
							<span class="gn_name">启用&nbsp;:&nbsp;</span>
							<c:if test="${systemParameter.cfenabled == '0' }">
							<input type="checkbox" class="checkbox" name="cfenabled2" value="" id="cfenabled2"/>
							</c:if>
							<c:if test="${empty systemParameter.cfenabled}">
							<input type="checkbox" class="checkbox" name="cfenabled2" value="" id="cfenabled2"/>
							</c:if>
							<c:if test="${systemParameter.cfenabled == '1' }">
							<input type="checkbox" class="checkbox" name="cfenabled2" value="" id="cfenabled2" checked="checked"/>
							</c:if>
							<input type="hidden"  name="cfenabled" id="cfenabled"/>
						</div>
					</div>
				</c:if>
				<div class="div_tj" style="margin-left: 140px">
					<c:if test="${empty systemParameter}">
						<div>
							<input onclick="qy()" class="input_submit bc" value="" id="button_submit" type="submit" style="margin-right: 30px;"/>
						</div>
						<div>
                            <input type="button" class="input_back fh" value="" onclick="back()"/>
						</div>
					</c:if>
					<c:if test="${not empty systemParameter}">
					<div>
                        <input onclick="qy()" class="input_submit bc" value="" id="button_submit" type="submit">
					</div>
					<div>
                        <input type="button" class="input_back fh" value="" onclick="back()"/>
					</div>
				</c:if>
				</div>
			</form>
		</div>
	</div>
</div>
</body>
<script type="text/javascript" src="<%=path%>/JQuery/jquery-1.8.2.js"></script>
<%@ include file="/WEB-INF/JSP/ajax.jsp"%>
<script type="text/javascript">


$(document).ready(function(){
	var type = "${type}"
	if(type == null || type == ''){
		
	}else{
        editAlert();
	}
})

function qy(){
	if($('#cfenabled2').is(':checked')) {
	    $("#cfenabled").val("1");
	}else{
		$("#cfenabled").val("0");
	}
}
$("#cfnumbers").blur(function(){
	//只能输入数字和小数点
	var re = /^\d+(?=\.{0,1}\d+$|$)/ 
	//理论油耗的值
	var shuzhi = $(this).val();
	//判断只能输入数字和小数点
	if(shuzhi == ""){
		$(".haoyou").css("display","none");
	}else if(!re.test(shuzhi)){
		$(".haoyou").css("display","inline");
		$(this).val("")
	}else{
		$(".haoyou").css("display","none");
	}
})

function back(){
		location = '<%=path%>/DrivingSys/querySysetmParamenter/look.action';
	}

//阻止表单提交
function submit2(){
	var name = $(".name").val();
	if(name == null || name == ''){
		alert("名称不能未空")
		return false
	}
    //提交后把提交变成不可用，可阻止表单重复提交
    $("input[type='submit']").attr("disabled", "disabled");
}

//验证名称是否重复
function yz() {
    var name = $(".name").val();
    $.ajax({
        url: '<%=path%>/DrivingSys/yzSystemParameter',
        type: "post",
        data: {'name': name},
        dataType: "json",
        success: function (json) {
            if (json == false) {
                alert("名称重复");
                $(".name").val("");
            } else {

            }
        },
        error: function () {
            alert("错误");
        }
    })
}

//验证名称是否重复
function yzEdit() {
    var name = $(".name").val();
    var name1 = $(".name").next().val();
    if (name == '' || name == null) {
        alert("名称不能未空");
    }
    if (name == name1) {

    } else {
        $.ajax({
            url: '<%=path%>/DrivingSys/yzSystemParameter',
            type: "post",
            data: {'name': name},
            dataType: "json",
            success: function (json) {
                if (json == false) {
                    alert("名称重复");
                    $(".name").val("");
                } else {

                }
            },
            error: function () {
                alert("错误");
            }
        })
    }
}
</script>

</html>